const http = require('http');
const hostname = 'zeus.query.enhancer';
const port = 80;

const server = http.createServer((req, res) => {
  if (req.url === '/hello') {
    res.statusCode = 200;
    res.setHeader('Content-Type', 'text/plain');
    res.end('hello world');
  } else if (req.url === '/ga-test') {
    res.statusCode = 200;
    res.setHeader('Content-Type', 'text/html');
    res.end(`
      <!DOCTYPE html>
      <html>
        <head>
          <title>Google Analytics 测试页面</title>
          <!-- Google tag (gtag.js) -->
          <script async src="https://www.googletagmanager.com/gtag/js?id=G-BYE88EHR7Z"></script>
          <script>
            window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
            gtag('js', new Date());
            gtag('config', 'G-BYE88EHR7Z');
          </script>
        </head>
        <body>
          <h1>Google Analytics 测试页面</h1>
          <p>这是一个用于测试 Google Analytics 的页面</p>
          <button onclick="gtag('event', 'button_click', {'event_category': 'engagement'})">
            测试事件按钮
          </button>
        </body>
      </html>
    `);
  } else {
    res.statusCode = 404;
    res.setHeader('Content-Type', 'text/plain');
    res.end('Not Found');
  }
});

server.listen(port, hostname, () => {
  console.log(`服务器运行在 http://${hostname}:${port}/`);
}); 